home *** CD-ROM | disk | FTP | other *** search
Java Source | 1997-02-27 | 1.4 KB | 63 lines | [TEXT/CWIE] |
- /* SK8 © 1997 Apple Computer, Inc.
- This code is protected under the current SK8 License
- See http://sk8.research.apple.com/ for more information
- Apple Research Laboratories
- */
-
-
- import java.io.*;
-
-
- public class textstream extends stream {
-
- // reading
-
- public final char readcharacter() throws IOException{
- if (!mDirection.equals("input")){
- throw new IOException ("can only read from input streams");
- } else {
- if (mInDataStream == null)
- setupStreams();
-
- return mInDataStream.readChar();
- }
- }
-
-
- public final String readline() throws IOException{
- if (!mDirection.equals("input")){
- throw new IOException ("can only read from input streams");
- } else {
- if (mInDataStream == null)
- setupStreams();
-
- return mInDataStream.readLine();
- }
- }
-
-
- //writing
-
- public final void writecharacter(char ch) throws IOException{
- if (!mDirection.equals("output")){
- throw new IOException ("can only write to output streams");
- } else {
- if (mOutDataStream == null)
- setupStreams();
-
- mOutDataStream.writeChar(ch);
- }
- }
-
-
- public final void writestring(String str) throws IOException{
- if (!mDirection.equals("output")){
- throw new IOException ("can only write to output streams. This stream is " + mDirection );
- } else {
- if (mOutDataStream == null)
- setupStreams();
-
- mOutDataStream.writeChars(str);
- }
- }
- }